var fs=require('fs');

//定义两个流
var myReadStream = fs.createReadStream(__dirname+'/readMe.txt','utf8');
var myWriteStream =fs.createWriteStream(__dirname+'/writeMe.txt');
//定义编码的另外一种方式：myReadStream.setEncoding('utf8');

//buffer显示，提高效率
//第一部分
// var data='';
// myReadStream.on('data',function(chunk){
//     console.log('new chunk received...');
//    // console.log(chunk);
//    data=data+chunk;
//    myWriteStream.write(chunk);
// })

// myReadStream.on('end',function(){
//     console.log(data);

// })

//第二部分
// var writeData='hello yexuan...';
// myWriteStream.write(writeData);
// myWriteStream.end();
// myWriteStream.on('finnsh',function () {
//     console.log('write finished...'); 
// })

//第三部分，管道
//myReadStream.pipe(myWriteStream);


